package org.example.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.TemplateIndex;
import com.qidian.mes.pojo.TemplateProduct;
import org.example.mapper.TemplateProductMapper;
import org.example.service.TemplateIndexService;
import org.example.service.TemplateProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 严伟伦
 * @Company 无
 * @Description
 * @Date: 2024/10/22 14:39
 */
@RestController
@RequestMapping("/templateProduct")
@CrossOrigin
public class TemplateProductController {

    @Autowired
    private TemplateProductService templateProductService;

    @GetMapping("/list")
    public MESResult list(@RequestParam("templateId") Long templateId, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return templateProductService.selectPage(templateId,page,limit);
    }

    @PostMapping("/add")
    public MESResult addTemplateProduct(@RequestBody TemplateProduct templateProduct){
        System.out.println("11111111111111111111111111111111111111111111111111111" + templateProduct);
        return templateProductService.addTemplateProduct(templateProduct);
    }

    @GetMapping("/selectTemplateProductById")
    public MESResult selectTemplateProductById(@RequestParam("recordId") int recordId){

        return templateProductService.selectTemplateProductById(recordId);
    }
    @PutMapping("/update")
    public MESResult updateTemplateProduct(@RequestBody TemplateProduct templateProduct){

        return templateProductService.updateTemplateProduct(templateProduct);
    }
}
